package com.brillilab.service.module.message.template.impl.instrument;

import com.brillilab.common.rocketmq.OnsMessageEnum;
import com.brillilab.common.rocketmq.OnsMessageVo;
import com.brillilab.domain.po.instrument.Instrument;
import com.brillilab.domain.po.instrument.InstrumentAppointment;
import com.brillilab.domain.po.message.Message;
import com.brillilab.domain.vo.instrument.AppointmentVo;
import com.brillilab.domain.vo.user.UserInfoVo;
import com.brillilab.service.logic.instrument.converter.AppointmentConverter;
import com.brillilab.service.module.message.enums.MessageTargetEnum;
import com.brillilab.service.module.message.template.AbstractMessageTemplate;
import com.brillilab.service.module.message.template.enums.MessageTypeEnum;
import lombok.Data;

@Data
public class AppointmentChangeTemplate extends AbstractMessageTemplate {
    private String labName;
    private Integer instrumentNo;
    private String instrumentName;
    private String startTime;
    private String endTime;

    public AppointmentChangeTemplate(Instrument instrument,InstrumentAppointment appointment,UserInfoVo userInfoVo) {
        super(userInfoVo.getLabId(),userInfoVo.getId());
        AppointmentVo appointmentVo=AppointmentConverter.appointmentToAppointmentVo(appointment);
        this.labName=userInfoVo.getLabName();
        this.labMemberId = userInfoVo.getLabMemberId();
        this.instrumentNo=instrument.getNo();
        this.instrumentName=instrument.getName();
        this.startTime=appointmentVo.getStartDate();
        this.endTime=appointmentVo.getEndDate();
        this.referId = appointmentVo.getId();
        super.setType(MessageTypeEnum.InstrumentAppointmentChange.getValue());
        super.setTitle("仪器预约修改");

        StringBuilder context=new StringBuilder();
        context.append("<span>您已修改预约：").append(this.labName)
                .append("，编号为").append(this.instrumentNo)
                .append("的仪器：").append(this.instrumentName)
                .append("，预约时间已修改为：").append(this.startTime)
                .append(" 到 ").append(this.endTime).append("</span>");
        super.setContent(context.toString());
        super.setAppContent(context.toString());
    }

}
